<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container p:nth-child(2) {
            background-color: yellow;
            color: black;
        }
        /* container里面的第三个段落 */
        .container p:nth-of-type(3) {
            background-color: red;
            color: white;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>nth-child vs nth-of-type 示例</h1>
        <p>这是一个段落。</p>
    <div>这是一个div。</div>
    <p>这是第二个段落。</p>
    <p>这是第三个段落。</p>
    <div>这是第二个div。</div>
    </div>
</body>
</html>